Blueprint Help Send comments on this topic.
Workspace Code

Glossary Item Box

Back to Entering Method Code

Entering Workspace Code

To enter Workspace data select the Pixellate Mthd and then Edit Code->Workspace Data Class... in the Right Click menu. This will open the workspace data structure header file.

The Initialise() function is automatically called by the CLiP infrastructure.

MyCircuit_PixellateMthdWorkspace.hpp

Uns MyCircuit_PixellateMthdWorkspaceElem::Process()
{
public:
   ... 
   Uns Initialise()
   {
      // this code is full of magic numbers, it is sufficient to know that it is
      // generating a lookup table of colours from black to red to yellow to white

      Float step  = 1.0f / NUM_LOOKUP_LEVELS;
      Float input = step;      // avoids problem of log(0)
      Float value;

      unsigned char red, green, blue;

      mColours[0] = 0;
      for ( Uns i = 1; i < NUM_LOOKUP_LEVELS; ++i )
      {
         value  = input * 47863000.0f; // magic number  10**(3*256/100)
         value  = log10f( value ); 
         value *= 100.0f;

         if ( value >= 767.0f )
         {
            red   = 255;
            green = 255;
            blue  = 255;
         }
         else if ( value >= 511.0f )
         {
            red   = 255;
            green = 255;
            blue  = (unsigned char)(value - 511.0f);
         }
         else if ( 
value >= 255.0f )
         {
            red   = 255;
            green = (unsigned char)(value - 255.0f);
            blue  = 0;
         }
         else
         {
            red   = (unsigned char) value;
            green = 0;
            blue  = 0
         }
         mColours[i] = ( 0xFF000000 & blue  << 24 ) | 
                       ( 0x00FF0000 & red   << 16 ) |
                       ( 0x0000FF00 & green <<  8 );

         input += step;
      }

      return TRUE;
   }

   // TODO: Add custom data access functions
   Uns* Colours(){ return mColous; }

private:
   // TODO: Add custom data member variables
   Uns mColours[NUM_LOOKUP_LEVELS];
}; 

ProjectHeader.hpp

...

// TODO: Reference any additional headers or defines you need
...

// Colour Map: R, G, B and Alpha
#define NUM_COLOUR_PLANES  4
#define NUM_LOOKUP_LEVELS  1000000

// number of rows in a band, minus 2, 1 row each side
#define NUM_ROWS    (GRID_SIZE/NB - 2)

#endif

Back to Entering Method Code